c++
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 5e5 + 5;
constexpr int M = 4e6 + 5;
int head[N], to[M], nxt[M], tot = 1;
void add(int u, int v) {
nxt[++tot] = head[u];
head[u] = tot;
to[tot] = v;
}
int dfn[N], low[N], timer;
bool is_bridge[M>>1];
int n, m, cnt;
void tarjan(int u, int in_e) {
dfn[u] = low[u] = ++timer;
for (int i = head[u]; i; i = nxt[i]) {
if ((i ^ 1) == in_e) continue;
int v = to[i];
if (!dfn[v]) {
tarjan(v, i);
low[u] = std::min(low[u], low[v]);
if (low[v] > dfn[u]) {
is_bridge[i >> 1] = true;
cnt++;
}
} else if (dfn[v] < dfn[u]) {
low[u] = std::min(low[u], dfn[v]);
}
}
}
void fc() {
std::cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
std::cin >> u >> v;
add(u, v);
add(v, u);
}
for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i,0);
std::cout << cnt << "\n";
for (int i = 1; i <= m; i++)
if (is_bridge[i]) std::cout << i << " ";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// std::cin>>t;
while (t--) fc();
return 0;
}